package com.fc.func;

import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.InputGroup;
import org.apache.flink.table.functions.ScalarFunction;
import org.postgresql.util.PGobject;
import java.sql.SQLException;
public class GeometryToString extends ScalarFunction {
    public String eval(@DataTypeHint(inputGroup = InputGroup.ANY) Object geoObj) throws SQLException {

        if (geoObj instanceof PGobject){
            return PGobject.class.cast(geoObj).getValue(); // 提取 WKT 字符串
        }else {
            return geoObj.toString();
        }
    }


    public static void main(String[] args) throws SQLException {
        GeometryToString g = new GeometryToString();
        System.out.println(g.eval("POINT(1 2)"));
    }


}